<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/Public/foundation/foundation.min.css">
    <script src="/Public/foundation/foundation.min.js"></script>
    <script src="/Public/foundation/modernizr.js"></script>
    <script src="/Public/jquery/jquery.min.js"></script>
    <script src="/Public/jquery/plugin"></script>
    <link rel="stylesheet" href="http://static.runoob.com/assets/foundation-icons/foundation-icons.css">
</head>
<body>
<nav class="top-bar" data-topbar>
    <ul class="title-area">
        <li class="name">
            <h1><a href="#">后台管理</a></h1>
        </li>
    </ul>
    <section class="top-bar-section">
        <ul class="right">
            <?php if($_SESSION['uname']== null): ?><li><a href="<?php echo U('login');?>">登录</a></li>
                <?php else: ?>
                <li><a href="">欢迎<?php echo (session('uname')); ?></a></li>
                <li><a href="<?php echo U('loginout');?>">退出</a></li><?php endif; ?>
        </ul>

    </section>
</nav>
<div>
    <div class="small-2 columns">
        <?php if(is_array($navs)): $i = 0; $__LIST__ = $navs;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><ul class="side-nav">
            <li>11</li>
        </ul><?php endforeach; endif; else: echo "" ;endif; ?>
    </div>
    <div class="small-10 columns">
        
    <button onclick="selectAl()">全选</button>
    <button onclick="unSelect()">反选</button>
    <button >添加</button>
    <table border="1" id="userTbl">
        <thead>
        <tr>
            <th><input type="checkbox" onclick="selectAll(this)"></th>
            <th>编号</th>
            <th>菜单名称</th>
            <th>菜单路径</th>
            <th>打开方式</th>
            <th>分组</th>
            <th>排序</th>
            <th style="text-align:center">操作</th>
        </tr>
        </thead>
        <tbody>
        <?php if(is_array($menus)): $i = 0; $__LIST__ = $menus;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><tr id="row_<?php echo ($v["menu_id"]); ?>">
                <td><input value="<?php echo ($v["menu_id"]); ?>" class="rowcb" type="checkbox"></td>
                <td><?php echo ($v["menu_id"]); ?></td>
                <td><?php echo ($v["mname"]); ?></td>
                <td><?php echo ($v["url"]); ?></td>
                <td><?php echo ($v["target"]); ?></td>
                <td>分组</td>
                <td>排序</td>
                <td>
                    <button onclick="delUser(<?php echo ($v["menu_id"]); ?>)">删除</button>
                    <button onclick="editUser(<?php echo ($v["menu_id"]); ?>)">修改</button>
                </td>
            </tr><?php endforeach; endif; else: echo "" ;endif; ?>
        </tbody>
    </table>
    <div id="page">
        <?php $__FOR_START_13064__=1;$__FOR_END_13064__=$pages;for($i=$__FOR_START_13064__;$i < $__FOR_END_13064__;$i+=1){ ?><span data-val="<?php echo ($i); ?>"><?php echo ($i); ?></span>|<?php } ?>
    </div>

<script>
    $(function(){
        //分页
        $('#page span').click(function(){
            var pagenum=$(this).attr('data-val');
            $.get('<?php echo U("getShow");?>',{p:pagenum},function(data) {
                var html='';
                for(var i in data){
                    html += '<tr><td><input value="<?php echo ($v["menu_id"]); ?>" class="rowcb" type="checkbox"></td><td>'+data[i].menu_id+'</td><td>'+data[i].mname+'</td><td>'+data[i].url+'</td><td>'+data[i].target+'</td>' +
                        '<td>分组</td><td>排序</td><td><button onclick="delUser('+data.menu_id+')">删除</button><button onclick="ediitUser('+data.menu_id+')">修改</button></td></tr>';
                }
                $a= $('#userTbl tbody').html(html);
                console.log($a);exit;
            });
        } );
    })
    function selectAll(obj) {
        var checkstatu = $(obj).prop('checked');
        $('.rowcb').prop('checked',checkstatu);
    }
    function selectAl() {
        $('.rowcb').prop('checked',true);
    }
    function unSelect() {
        $('.rowcb').prop('checked',function (index,val) {
            return !val;
        });
    }
</script>

    </div>
</div>
</body>
</html>